function getLocalName() {
    navigator.globalization.getLocaleName(
        function (local) {
            document.getElementById("globInfo").innerHTML = local.value;
        },
        function () {alert('Error getting language\n');}
    );
}
function getPreferredLanguage() {
    navigator.globalization.getPreferredLanguage(
        function (language) {
            document.getElementById("globInfo").innerHTML = language.value;
        },
        function () {alert('Error getting language\n');}
    );
}

function dateToString() {
    navigator.globalization.dateToString(
        new Date(),
        function (date) { document.getElementById("globDateInfo").innerHTML = date.value; },
        function () { alert('Error getting dateString\n'); },
        { formatLength: 'short', selector: 'date and time' }
    );
}

function stringToDate() {
    navigator.globalization.stringToDate(
        '2012/7/7',
        function (date) {alert('month:' + date.month +
            ' day:'  + date.day   +
            ' year:' + date.year  + '\n');},
        function () {alert('Error getting date\n');},
        {selector: 'date'}
    );
}

function getDatePattern() {
    navigator.globalization.getDatePattern(
        function (date) { alert('pattern: ' + date.pattern + '\n'); },
        function () { alert('Error getting pattern\n'); },
        { formatLength: 'short', selector: 'date and time' }
    );
}

function getDateNames() {
    navigator.globalization.getDateNames(
        function (names) {
            for (var i = 0; i < names.value.length; i++) {
                alert('month: ' + names.value[i] + '\n');
            }
        },
        function () { alert('Error getting names\n'); },
        { type: 'wide', item: 'months' }
    );
}

function isDayLightSavingsTime() {
    navigator.globalization.isDayLightSavingsTime(
        new Date(),
        function (date) {alert('dst: ' + date.dst + '\n');},
        function () {alert('Error getting names\n');}
    );
}

function  getFirstOfWeek() {
    navigator.globalization.getFirstDayOfWeek(
        function (day) {alert('day: ' + day.value + '\n');},
        function () {alert('Error getting day\n');}
    );
}

function numberToString() {
    navigator.globalization.numberToString(
        3.1415926,
        function (number) {alert('number: ' + number.value + '\n');},
        function () {alert('Error getting number\n');},
        {type:'decimal'}
    );
}

function getNumberPattern() {
    navigator.globalization.getNumberPattern(
        function (pattern) {alert('pattern: '  + pattern.pattern  + '\n' +
            'symbol: '   + pattern.symbol   + '\n' +
            'fraction: ' + pattern.fraction + '\n' +
            'rounding: ' + pattern.rounding + '\n' +
            'positive: ' + pattern.positive + '\n' +
            'negative: ' + pattern.negative + '\n' +
            'decimal: '  + pattern.decimal  + '\n' +
            'grouping: ' + pattern.grouping);},
        function () {alert('Error getting pattern\n');},
        {type:'decimal'}
    );
}

function stringToNumber() {
    navigator.globalization.stringToNumber(
        '1234.56',
        function (number) {alert('number: ' + number.value + '\n');},
        function () {alert('Error getting number\n');},
        {type:'decimal'}
    );
}

function getCurrencyPattern() {
    navigator.globalization.getCurrencyPattern(
        'CNY',
        function (pattern) {
            alert('pattern: '  + pattern.pattern  + '\n' +
                'code: '     + pattern.code     + '\n' +
                'fraction: ' + pattern.fraction + '\n' +
                'rounding: ' + pattern.rounding + '\n' +
                'decimal: '  + pattern.decimal  + '\n' +
                'grouping: ' + pattern.grouping);
        },
        function () { alert('Error getting pattern\n'); }
    );
}

